/*
 * Author: Alberto De Pena
 * Applied Algorithms
 * plinko.cpp
*/
#include <iostream>
#include <fstream>
using namespace std;

void main()
{
    ifstream fin;
    ofstream fout;

	fin.open( "plinko.in" );
    fout.open( "plinko.out" );

    int number, total;
	int gameBoard[100][100]; 

    fin >> number;

    while( number > 0 )
    {
        for( int i = 0; i < number; i++ )
        {
            for( int j = 0; j <= i; j++ )
            {
                fin >> gameBoard[i][j];
            }
        }

        for( int i = 0; i < number - 1; i++ )
        {
            for( int j = 0; j <= i; j++ )
            {
                if( i == 0 )
                {
                    gameBoard[i + 1][j] += gameBoard[i][j];
                    gameBoard[i + 1][j + 1] += gameBoard[i][j];
                }
                else if( j == 0 )
                {
                    gameBoard[i+1][j] +=  gameBoard[i][j];
                    if( gameBoard[i][j] > gameBoard[i][j + 1] )
                        gameBoard[i + 1][j + 1] += gameBoard[i][j];
                }
                else if( j == i )
                {
                    gameBoard[i + 1][j + 1] += gameBoard[i][j];
                    if(gameBoard[i][j] > gameBoard[i][j - 1])
                        gameBoard[i + 1][j] += gameBoard[i][j];
                }
                else
                {
                     if( gameBoard[i][j]  >= gameBoard[i][j + 1] )
                        gameBoard[i + 1][j + 1] += gameBoard[i][j];

                     if( gameBoard[i][j] > gameBoard[i][j - 1] )
                         gameBoard[i + 1][j] += gameBoard[i][j];
                }
            }
        }

        total = 0;
        for( int i = 0; i < number; i++ )
        {
            if( gameBoard[number - 1][i] > total )
                total = gameBoard[number - 1][i];
        }

        fout << total << endl;
        fin >> number;
    }
    fin.close();
    fout.close();
}

